import { Button } from 'antd';
import type React from 'react';
import {
  attachOldStation,
  detachOldStation,
} from '@/components/MapView/Mapless';
import styles from '../../index.module.less';
import type { TestControlProps } from '../types';

const Index: React.FC<TestControlProps> = ({ maplessRef }) => {
  const onDrawStations2 = () => {
    const sMan2 = attachOldStation(maplessRef.current, 'sm2');
    sMan2?.drawStations([
      {
        id: '1',
        name: '测试站点2-1',
        longitude: 113.266,
        latitude: 23.131,
        type: '',
        category: 'portable',
        state: 'fault',
        selected: true,
      },
      {
        id: '2',
        name: '测试站点2-2',
        longitude: 113.276,
        latitude: 23.131,
        type: '',
        category: 'sensorRFeye',
        state: 'busy',
      },
    ]);
    sMan2?.on('stationsSelected', (e) => {
      console.log('stationsSelected', e);
    });
  };

  const onClearStations2 = () => {
    detachOldStation(maplessRef.current, 'sm2');
  };

  return (
    <div className={styles.test}>
      <Button onClick={onDrawStations2}>绘制Old站点列表2</Button>
      <Button onClick={onClearStations2}>清除Old站点列表2</Button>
    </div>
  );
};

export default Index;
